First load the data and required packages
library(ggplot2); library(dplyr);library(tidyverse); library(rmcorr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ tibble 3.1.8 ✔ purrr 0.3.4
## ✔ tidyr 1.1.4 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(bestNormalize); library(ggpubr)
df <- read.csv('Study 1 anon.csv')
How do average levels of politicization and slant (perceptions) associate with trust?
# Rename some variables for consistency
names(df)[names(df) == 'Slant_K12'] <- 'slant_K12'
names(df)[names(df) == 'Polit_K12'] <- 'polit_K12'
names(df)[names(df) == 'Slant_Cong'] <- 'slant_Cong'
names(df)[names(df) == 'Polit_Cong'] <- 'polit_Cong'
names(df)[names(df) == 'Trust_Econ'] <- 'Trust_econ'
names(df)[names(df) == 'Trust_Pharm'] <- 'Trust_pharm'
names(df)[names(df) == 'Trust_Sci'] <- 'Trust_sci'
all_groups <- c()
for (n in names(df %>% select(starts_with("slant_")))){
all_groups <- c(all_groups,substring(n,unlist(gregexpr('_', n))[1]+1))
}
trust <- c()
slant <- c()
polit <- c()
for (g in all_groups){
trust <- c(trust,mean(df[,paste("Trust_",g,sep='')],na.rm=TRUE))
slant <- c(slant,mean(df[,paste("slant_",g,sep='')],na.rm=TRUE))
polit <- c(polit,mean(df[,paste("polit_",g,sep='')],na.rm=TRUE))
}
df_means <- data.frame(all_groups,trust,slant,polit)
a <- ggplot(df_means, aes(x=slant, y = trust)) +
geom_point() + geom_smooth(method=glm) +
ylab('Mean Org. Trust') + xlab('Mean Org. Slant') +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.x=element_text(size=15),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1))+
coord_cartesian(xlim = c(20,80), ylim = c(1.5,5.0))
b <- ggplot(df_means, aes(x=polit, y = trust)) +
geom_point() + geom_smooth(method=glm) +
ylab('Mean Org. Trust') + xlab('Mean Org. Politicization') +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.x=element_text(size=15),
axis.title.y=element_blank(),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1))+
coord_cartesian(xlim = c(1,6), ylim = c(1.5,5.0))
ggarrange(a, b, labels = c("", ""),ncol = 2, nrow = 1, widths=c(1,0.93))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure1-Mean-slant-polit-trust.png",width = 8,height = 4,units = "in",dpi = 300)
cor.test(df_means$slant,df_means$trust,method='pearson',conf.level=0.95)
##
## Pearson's product-moment correlation
##
## data: df_means$slant and df_means$trust
## t = -0.90884, df = 38, p-value = 0.3692
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.4374889 0.1735369
## sample estimates:
## cor
## -0.1458572
cor.test(df_means$polit,df_means$trust,method='pearson',conf.level=0.95)
##
## Pearson's product-moment correlation
##
## data: df_means$polit and df_means$trust
## t = -7.1594, df = 38, p-value = 1.498e-08
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.8650951 -0.5842007
## sample estimates:
## cor
## -0.7578022
How do folks on the left and the right differ regarding these relationships toward particular institutions?
plot_politicization <- function(df, polit_col, slant_col,include_y,include_legend) {
df_reg <- df %>%
select(!!sym(polit_col), !!sym(slant_col), Ideology) %>%
drop_na() %>%
mutate(Party = ifelse(Ideology < 4, "Left", ifelse(Ideology == 4, "Center", "Right"))) %>%
filter(Party != "Center")
df_reg$Party <- factor(df_reg$Party, levels = c('Left','Center','Right'))
ggplot(df_reg, aes(x=!!sym(slant_col), y = !!sym(polit_col), color=Party,fill=Party)) +
geom_point(alpha = 0.5, size =0.5) +
geom_jitter(height = 0.5,width = 0.0,alpha = 0.5, size =0.5) +
geom_smooth(method=glm) +
scale_color_manual(values=c("#0000ff",'#ff0803'))+scale_fill_manual(values=c("#0000ff",'#ff0803'))+
ylab(ifelse(include_y, "Politicization", "")) +
xlab(str_to_title(str_replace(slant_col, "_", " "))) +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.x=element_text(size=15),
axis.title.y=element_text(size=15),
legend.position = ifelse(include_legend,'right',"none"),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1)) +
coord_cartesian(xlim = c(0,100), ylim = c(0,6.5))
}
# use the function for each set of columns
a <- plot_politicization(df, "polit_vet", "slant_vet",T,F)
b <- plot_politicization(df, "polit_police", "slant_police",F,F)
c <- plot_politicization(df, "polit_prof", "slant_prof",F,T)
# arrange the plots
ggarrange(a, b, c, labels = c("", "", ""),ncol = 3, nrow = 1, widths=c(0.85,0.78,1))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure2-Ideologyxslant-politicization_1.png",width = 10,height = 3.5,units = "in",dpi = 300)
Next we want to look at ideological congruence for several organizations:
plot_congruence <- function(data, group,include_y,xlab_use,include_legend){
group_prefix <- paste0("_", group)
df_reg <- data %>%
select(ends_with(group_prefix), Ideology) %>%
drop_na() %>%
mutate(Slant_2 = get(paste0('slant',group_prefix)) - 50,
Ideo_2 = Ideology - 4,
Matched_Bias = Slant_2 * Ideo_2,
Congruence = case_when(
is.na(Matched_Bias) ~ NA_character_,
Matched_Bias < 0 ~ "Incongruent",
Matched_Bias > 0 ~ "Congruent",
TRUE ~ 'Neutral'
)
) %>%
filter(Congruence != 'Neutral') %>% # Remove if you want Neutral
drop_na()
df_reg$Congruence <- factor(df_reg$Congruence, levels = c('Incongruent','Congruent')) #'Neutral','Congruent'))
a <- ggplot(df_reg, aes(x = get(paste0("polit",group_prefix)), y = get(paste0("Trust",group_prefix)), color = Congruence, fill=Congruence)) +
geom_point(alpha = 0.75, size = 0.5) +
geom_jitter(height = 0.5, width = 0.5, alpha = 0.5, size = 0.75) +
geom_smooth(method = glm) +
scale_color_manual(values = c('#FF5733',"#007200")) +
scale_fill_manual(values = c('#FF5733',"#007200")) +
#scale_color_manual(values = c('#FF5733','#d4af37',"#007200")) + # If you want neutral
#scale_fill_manual(values = c('#FF5733','#d4af37',"#007200")) +
ylab(ifelse(include_y, "Trust", "")) +
xlab(paste0('Politicization (', xlab_use, ')')) +
theme(
axis.text = element_text(size = 15),
axis.title = element_text(size = 15),
axis.title.x = element_text(size = 15),
legend.position = ifelse(include_legend,'right',"none"),
panel.background = element_rect(fill = 'white'),
plot.background = element_rect(fill = 'transparent', color = NA),
axis.text.x = element_text(size = 8, angle = 90),
panel.border = element_rect(colour = "black", fill = NA, size = 1)
)
return(a)
}
a1 = plot_congruence(df, "vet",T,"Vets",F)
a2 = plot_congruence(df, "police",F,"Police",T) # Depending on order of column either 2 or 3 ends with 'T'
a3 = plot_congruence(df, "prof",F,"Professors",F)
b1 = plot_congruence(df, "toll",T,"Toll Booth",F)
b2 = plot_congruence(df, "SC",F,"Supreme Court",T)
b3 = plot_congruence(df, "WHO",F,"WHO",F)
c1 = plot_congruence(df, "chefs",T,"Chefs",F)
c2 = plot_congruence(df, "church",F,"Church",T)
c3 = plot_congruence(df, "PETA",F,"PETA",F)
# Order for center, right, left (columns)
#ggarrange(a1, a2, a3, b1, b2, b3, c1, c2, c3, labels = c("", "", "","", "", "","", "", ""),ncol = 3, nrow = 3, widths=c(0.85,0.78,1.15))
#ggsave("plots/Figure3-Congrencextrust-politicization.png",width = 10,height = 10.5,units = "in",dpi = 300)
# Order for left, center, right (columns)
ggarrange(a3, a1, a2, b3, b1, b2, c3, c1, c2, labels = c("", "", "","", "", "","", "", ""),ncol = 3, nrow = 3, widths=c(0.85,0.78,1.15))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure3-Congrencextrust-politicizationb.png",width = 10,height = 10.5,units = "in",dpi = 300)
Another figure with significant interactions for 3 other groups
a1 = plot_congruence(df, "econ",T,"Economists",F)
b1 = plot_congruence(df, "holly",F,"Hollywood",F)
c1 = plot_congruence(df, "think",F,"Think Tanks",T)
ggarrange(a1, b1, c1, labels = c("", "", ""),ncol = 3, nrow = 1, widths=c(0.85,0.78,1.15))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure3b-Congrencextrust-politicization.png",width = 10,height = 3.5,units = "in",dpi = 300)
Here, we need to load the data from study 2:
library(readxl)
df_2 <- read_excel('Study 2 anon.xlsx')
# Rename a few columns for consistency
names(df_2)[names(df_2) == 'TrustWHO'] <- 'TrustWho'
names(df_2)[names(df_2) == 'TrustFIRE'] <- 'TrustFire'
names(df_2)[names(df_2) == 'SupportWHO'] <- 'SupportWho'
names(df_2)[names(df_2) == 'SupportFIRE'] <- 'SupportFire'
For this next figure, I want to look at trust for the congruent, incongruent, and neutral groups from Study2
plot_congruence_2 <- function(data, group,include_y,xlab_use,include_legend,trust){
df_reg <- data %>%
select(ends_with(group), Ideology) %>%
drop_na() %>%
mutate(
Slant_2 = get(paste0('Slant',group)) - 4,
Ideo_2 = Ideology - 4,
Matched_Bias = Slant_2 * Ideo_2,
Congruence = case_when(
is.na(Matched_Bias) ~ NA_character_,
Matched_Bias < 0 ~ "Incongruent",
Matched_Bias > 0 ~ "Congruent",
TRUE ~ "Neutral"
)
) %>%
drop_na() %>%
mutate(Congruence = factor(Congruence, levels = c("Incongruent","Neutral", "Congruent")))
if (group == "Fire" | group == 'Doc'){
print(nrow(df_reg %>% filter(Congruence == 'Incongruent')))
print(nrow(df_reg %>% filter(Congruence == 'Neutral')))
print(nrow(df_reg %>% filter(Congruence == 'Congruent')))
#df_reg <- df_reg %>% filter(Congruence == 'Neutral')
}
a <- ggplot(df_reg, aes(x=get(paste0("Polit",group)), y = get(paste0(ifelse(trust, "Trust", "Support"),group)), color = Congruence)) +
geom_point(alpha = 0.5, size =0.5) + geom_jitter(height = 0.5,width = 0.5,alpha = 0.5, size =0.5) + geom_smooth(method=glm,aes(fill=Congruence)) +
ylim(0.5, 6.2) +
scale_color_manual(values=c('Incongruent' = '#FF5733','Neutral' = '#d4af37','Congruent' = "#007200"),drop=FALSE)+
scale_fill_manual(values=c('Incongruent' = '#FF5733','Neutral' = '#d4af37','Congruent' = "#007200"),drop=FALSE)+
ylab(ifelse(include_y, ifelse(trust, "Trust", "Support"), "")) +
xlab(paste0('Politicization (', xlab_use, ')')) +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.x=element_text(size=15),
legend.position = ifelse(include_legend,'right',"none"),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1))
return(a)
}
a1 = plot_congruence_2(df_2, "Prof",T,"Professors",F,T)
a2 = plot_congruence_2(df_2, "Fire",F,"Fire",F,T)
## [1] 49
## [1] 504
## [1] 47
a3 = plot_congruence_2(df_2, "Police",F,"Police",T,T)
b1 = plot_congruence_2(df_2, "Who",T,"WHO",F,T)
b2 = plot_congruence_2(df_2, "Doc",F,"Doctors",F,T)
## [1] 61
## [1] 479
## [1] 50
b3 = plot_congruence_2(df_2, "Judge",F,"Judges",T,T)
ggarrange(a1, a2, a3, b1, b2, b3, labels = c("", "", "","", "", "","", "", ""),ncol = 3, nrow = 2, widths=c(0.85,0.78,1.15))
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 34 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 19 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 12 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing missing values (geom_point).
ggsave("plots/Figure4-Study-2_Congrencextrust-politicization_2.png",width = 10,height = 7,units = "in",dpi = 300)
We will create a similar figure to Fig. 4, but with support instead of trust
a1 = plot_congruence_2(df_2, "Prof",T,"Professors",F,F)
a2 = plot_congruence_2(df_2, "Fire",F,"Fire",F,F)
## [1] 49
## [1] 504
## [1] 47
a3 = plot_congruence_2(df_2, "Police",F,"Police",T,F)
b1 = plot_congruence_2(df_2, "Who",T,"WHO",F,F)
b2 = plot_congruence_2(df_2, "Doc",F,"Doctors",F,F)
## [1] 61
## [1] 479
## [1] 50
b3 = plot_congruence_2(df_2, "Judge",F,"Judges",T,F)
ggarrange(a1, a2, a3, b1, b2, b3, labels = c("", "", "","", "", "","", "", ""),ncol = 3, nrow = 2, widths=c(0.85,0.78,1.15))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 13 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 5 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 3 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure5-CongrencexSupport-politicization_2.png",width = 10,height = 7,units = "in",dpi = 300)
We now want to look at our results from study 3. First, let’s load the data
df_3 = read.csv('Study 3 anon.csv')
#df_3$TrustProf<- df_3$Trust_Prof + df_3$Trust_Prof.0 + df_3$Trust_Prof.1
#df_3$PolitProf <- df_3$Polit_Prof + df_3$Polit_Prof.0 + df_3$Polit_Prof.1
#df_3$SlantProf <- df_3$Slant_Prof + df_3$Slant_Prof.0 + df_3$Slant_Prof.1
#df_3$TrustPolice <- df_3$Trust_police + df_3$Trust_Police.0 + df_3$Trust_Police.1
#df_3$PolitPolice <- df_3$Polit_Police + df_3$Polit_Police.0 + df_3$Polit_Police.1
#df_3$SlantPolice <- df_3$Slant_Police + df_3$Slant_Police.0 + df_3$Slant_Police.1
Next, we want to look at the relationship betweeen trust and politicization based on folks’ ideology
plot_parties <- function(data, group,include_y,xlab_use,include_legend,trust){
data$party <- ifelse(is.na(data$Ideology), NA,
ifelse(data$Ideology < 4, "Left-leaning",
ifelse(data$Ideology == 4, "Central", "Right-leaning")))
data$party <- factor(data$party, levels = c('Left-leaning','Central','Right-leaning'))
a <- ggplot(data, aes(x=get(paste0('Polit',group)), y = get(paste0(ifelse(trust, "Trust", "Support"),group)), color=party)) +
geom_point(alpha = 0.5, size =0.5) + geom_jitter(height = 0.5,width = 0.5,alpha = 0.5, size =0.5) + geom_smooth(method=glm,aes(fill=party)) +
scale_color_manual(values=c('blue','gray',"red"))+ scale_fill_manual(values=c('blue','gray',"red"))+
xlab(paste0('Politicization (',xlab_use,')')) +
ylab(ifelse(include_y, ifelse(trust, "Trust", "Support"), "")) +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.y = element_text(size=15),
axis.title.x=element_text(size=15),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
legend.position = ifelse(include_legend,'right',"none"),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1))
return(a)
}
df_reg <- df_3 %>% select(Ideology,ACProfPass,TrustProf,PolitProf) %>% drop_na() %>% filter(ACProfPass == 1)
a1 <- plot_parties(df_reg,'Prof',T,'Professors',F,T)
df_reg <- df_3 %>% select(Ideology,ACPolicePass,TrustPolice,PolitPolice) %>% drop_na() %>% filter(ACPolicePass == 1)
b1 <- plot_parties(df_reg,'Police',F,'Police',T,T)
ggarrange(a1, b1, labels = c("", ""),ncol = 2, nrow = 1, widths=c(0.85,1.15))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/FigureX-Partyxpoliticization-trust.png",width = 8,height = 3.5,units = "in",dpi = 300)
plot_congruence_2 <- function(data, group,include_y,xlab_use,include_legend,trust){
df_reg <- data %>%
select(ends_with(group), Ideology) %>%
drop_na() %>%
mutate(
Slant_2 = get(paste0('Slant',group)) - 4,
Ideo_2 = Ideology - 4,
Matched_Bias = Slant_2 * Ideo_2,
Congruence = case_when(
is.na(Matched_Bias) ~ NA_character_,
Matched_Bias < 0 ~ "Incongruent",
Matched_Bias > 0 ~ "Congruent",
TRUE ~ "Neutral"
)
) %>%
drop_na() %>%
mutate(Congruence = factor(Congruence, levels = c("Incongruent","Neutral", "Congruent")))
if (group == "Fire" | group == 'Doc'){
print(nrow(df_reg %>% filter(Congruence == 'Incongruent')))
print(nrow(df_reg %>% filter(Congruence == 'Neutral')))
print(nrow(df_reg %>% filter(Congruence == 'Congruent')))
df_reg <- df_reg %>% filter(Congruence == 'Neutral')
}
a <- ggplot(df_reg, aes(x=get(paste0("Polit",group)), y = get(paste0(ifelse(trust, "Trust", "Support"),group)), color = Congruence)) +
geom_point(alpha = 0.5, size =0.5) + geom_jitter(height = 0.5,width = 0.5,alpha = 0.5, size =0.5) + geom_smooth(method=glm,aes(fill=Congruence)) +
ylim(0.5, 6.2) +
scale_color_manual(values=c('Incongruent' = '#FF5733','Neutral' = '#d4af37','Congruent' = "#007200"),drop=FALSE)+
scale_fill_manual(values=c('Incongruent' = '#FF5733','Neutral' = '#d4af37','Congruent' = "#007200"),drop=FALSE)+
ylab(ifelse(include_y, ifelse(trust, "Trust", "Support"), "")) +
xlab(paste0('Politicization (', xlab_use, ')')) +
theme(axis.text=element_text(size=15),
axis.title=element_text(size=15),
axis.title.x=element_text(size=15),
legend.position = ifelse(include_legend,'right',"none"),
panel.background = element_rect(fill='white'),
plot.background = element_rect(fill='transparent', color=NA),
axis.text.x=element_text(size=8, angle=90),
panel.border = element_rect(colour = "black", fill=NA, size=1))
return(a)
}
df_reg <- df_3 %>% select(Ideology,ACProfPass,TrustProf,PolitProf,SlantProf) %>% drop_na() %>% filter(ACProfPass == 1)
a1 <- plot_congruence_2(df_reg,'Prof',T,'Professors',F,T)
df_reg <- df_3 %>% select(Ideology,ACPolicePass,TrustPolice,PolitPolice,SlantPolice) %>% drop_na() %>% filter(ACPolicePass == 1)
b1 <- plot_congruence_2(df_reg,'Police',F,'Police',T,T)
ggarrange(a1, b1, labels = c("", ""),ncol = 2, nrow = 1, widths=c(0.85,1.15))
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 7 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 10 rows containing missing values (geom_point).
ggsave("plots/Figure7-Congruencexpoliticization-trust.png",width = 8,height = 3.5,units = "in",dpi = 300)
# Create Figure 8 by looking at support
df_reg <- df_3 %>% select(Ideology,ACProfPass,SupportProf,PolitProf,SlantProf) %>% drop_na() %>% filter(ACProfPass == 1)
a1 <- plot_congruence_2(df_reg,'Prof',T,'Professors',F,F)
df_reg <- df_3 %>% select(Ideology,ACPolicePass,SupportPolice,PolitPolice,SlantPolice) %>% drop_na() %>% filter(ACPolicePass == 1)
b1 <- plot_congruence_2(df_reg,'Police',F,'Police',T,F)
ggarrange(a1, b1, labels = c("", ""),ncol = 2, nrow = 1, widths=c(0.85,1.15))
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/Figure8-Congruencexpoliticization-support.png",width = 8,height = 3.5,units = "in",dpi = 300)
df_reg <- df_3 %>% select(Ideology,PolitProf,SlantProf,TrustProf,SupportProf, ACProfPass) %>% drop_na() %>% filter(ACProfPass == 1)
df_reg <- df_reg %>%
select(ends_with('Prof'), Ideology) %>%
drop_na() %>%
mutate(
Slant_2 = get(paste0('Slant','Prof')) - 4,
Ideo_2 = Ideology - 4,
Matched_Bias = Slant_2 * Ideo_2,
Congruence = case_when(
is.na(Matched_Bias) ~ NA_character_,
Matched_Bias < 0 ~ "Incongruent",
Matched_Bias > 0 ~ "Congruent",
TRUE ~ "Neutral"
)
) %>%
drop_na() %>%
mutate(Congruence = factor(Congruence, levels = c("Incongruent","Neutral", "Congruent")))
# Get correlations
df_c <- df_reg %>% filter(Congruence == "Congruent")
cor.test(df_c$PolitProf,df_c$TrustProf)
##
## Pearson's product-moment correlation
##
## data: df_c$PolitProf and df_c$TrustProf
## t = -1.6628, df = 332, p-value = 0.0973
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.19627858 0.01659814
## sample estimates:
## cor
## -0.09087827
cor.test(df_c$PolitProf,df_c$SupportProf)
##
## Pearson's product-moment correlation
##
## data: df_c$PolitProf and df_c$SupportProf
## t = -2.0325, df = 332, p-value = 0.0429
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.215609647 -0.003588358
## sample estimates:
## cor
## -0.1108602
df_reg <- df_3 %>% select(Ideology,ACPolicePass,SupportPolice,TrustPolice,PolitPolice,SlantPolice) %>% filter(ACPolicePass == 1)
df_reg <- df_reg %>%
select(ends_with('Police'), Ideology) %>%
drop_na() %>%
mutate(
Slant_2 = get(paste0('Slant','Police')) - 4,
Ideo_2 = Ideology - 4,
Matched_Bias = Slant_2 * Ideo_2,
Congruence = case_when(
is.na(Matched_Bias) ~ NA_character_,
Matched_Bias < 0 ~ "Incongruent",
Matched_Bias > 0 ~ "Congruent",
TRUE ~ "Neutral"
)
) %>%
drop_na() %>%
mutate(Congruence = factor(Congruence, levels = c("Incongruent","Neutral", "Congruent")))
df_c <- df_reg %>% filter(Congruence == "Congruent")
cor.test(df_c$PolitPolice,df_c$TrustPolice)
##
## Pearson's product-moment correlation
##
## data: df_c$PolitPolice and df_c$TrustPolice
## t = -3.6853, df = 294, p-value = 0.0002719
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.31655482 -0.09848864
## sample estimates:
## cor
## -0.2101337
cor.test(df_c$PolitPolice,df_c$SupportPolice)
##
## Pearson's product-moment correlation
##
## data: df_c$PolitPolice and df_c$SupportPolice
## t = -3.0925, df = 294, p-value = 0.002175
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.28571666 -0.06480035
## sample estimates:
## cor
## -0.1774936
Finally, we’ll make one more figure that is much like the previous, but with support
df_reg <- df_3 %>% select(Ideology,ACProfPass,SupportProf,PolitProf,SlantProf) %>% drop_na() %>% filter(ACProfPass == 1)
a1 <- plot_parties(df_reg,'Prof',T,'Professors',F,F)
df_reg <- df_3 %>% select(Ideology,ACPolicePass,SupportPolice,PolitPolice,SlantPolice) %>% drop_na() %>% filter(ACPolicePass == 1)
b1 <- plot_parties(df_reg,'Police',F,'Police',T,F)
ggarrange(a1, b1, labels = c("", ""),ncol = 2, nrow = 1, widths=c(0.85,1.15))
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ggsave("plots/FigureXX-Partyxpoliticization-support.png",width = 8,height = 3.5,units = "in",dpi = 300)